package thread.simulation;

import java.util.Random;

/**
 * Title：
 * Description：
 * Created by Myth on 4/18/2017.
 */
public class Producer implements Runnable {
    private MyNumber myNumber = null;
    Random random = new Random(255); //生成随机数
    public Producer(MyNumber myNumber) {
        this.myNumber = myNumber;
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(300);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            myNumber.setNumber(random.nextInt(10));
        }
    }




}
